package com.lagou.serializer;

import com.alibaba.fastjson.JSON;
import java.io.IOException;

public class JSONSerializer implements Serializer{

    //java对象转换为二进制
    public byte[] srializer(Object object) throws IOException {
        return JSON.toJSONBytes(object);
    }

    //二进制转换成java对象
    public <T> T deSerializer(Class<T> z, byte[] bytes) throws IOException {
        return JSON.parseObject(bytes,z);
    }
}
